﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Common;
using EcSalseManage.App_Code;
using System.IO;
using System.Net;

namespace EcSalseManage.EcSalse
{
    public partial class Salse_Detail : System.Web.UI.Page
    {
        public string renewID = "";
        #region 页面初始化
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                if (!CommonFunction.isInPrev("Project_Deal_0001"))
                {
                    Response.Redirect("../Error/Perm_Error.aspx");
                }
                if (!CommonFunction.isInPrev("Project_Deal_0002"))
                {
                    this.btnSubmit.Enabled = false;
                }
                if (!CommonFunction.isInPrev("Project_Deal_0003"))
                {
                    this.btnDelete.Enabled = false;
                }

                #region 初始化加载数据
              

                DataSet ds = new DataSet();

                DataAccess.Operate.DA_Report_Attach_Inherit Report_Attach_Inherit = new DataAccess.Operate.DA_Report_Attach_Inherit();
                ds = Report_Attach_Inherit.FindLibrary();
                Common.Common_Function.DropDownListBind(ddlFileType, ds.Tables[0], "Report_File_ID", "Report_File_Name", "", "--请选择附件类型--");
                this.btnUpLoad.Attributes.Add("onclick", "return checkUpload();");

                wsKDHR.Service wsKDHRMS = new wsKDHR.Service();
                DataAccess.Operate.DA_Project_Department_Inherit Project_Department_Inherit = new DataAccess.Operate.DA_Project_Department_Inherit();
                DataAccess.Operate.DA_Project_SignType_Inherit Project_SignType_Inherit = new DataAccess.Operate.DA_Project_SignType_Inherit();
                DataAccess.Operate.DA_Project_Present_Inherit Project_Present_Inherit = new DataAccess.Operate.DA_Project_Present_Inherit();
                DataAccess.Operate.DA_Project_Province_Inherit Project_Province_Inherit = new DataAccess.Operate.DA_Project_Province_Inherit();
                DataAccess.Operate.DA_Project_ProductType_Inherit Project_ProductType_Inherit = new DataAccess.Operate.DA_Project_ProductType_Inherit();
                DataAccess.Operate.DA_Project_AgencyType_Inherit Project_AgencyType_Inherit = new DataAccess.Operate.DA_Project_AgencyType_Inherit();
                DataAccess.Operate.DA_Project_Encourage_Inherit Project_Encourage1_Inherit = new DataAccess.Operate.DA_Project_Encourage_Inherit();
                DataAccess.Operate.DA_Project_Lease1_Inherit Project_Lease1_Inherit = new DataAccess.Operate.DA_Project_Lease1_Inherit();
                DataAccess.Operate.DA_Project_AccountCycle_Inherit Project_AccountCycle_Inherit = new DataAccess.Operate.DA_Project_AccountCycle_Inherit();
                DataAccess.Operate.DA_Project_AccountCondition_Inherit Project_AccountCondition_Inherit = new DataAccess.Operate.DA_Project_AccountCondition_Inherit();
                DataAccess.Operate.DA_Project_BidderAccountCondition_Inherit Project_BidderAccountCondition_Inherit = new DataAccess.Operate.DA_Project_BidderAccountCondition_Inherit();
                DataAccess.Operate.DA_Project_SalseAccountCondition_Inherit Project_SalseAccountCondition_Inherit = new DataAccess.Operate.DA_Project_SalseAccountCondition_Inherit();
                DataAccess.Operate.DA_Project_Referral_Inherit Project_Referral_Inherit = new DataAccess.Operate.DA_Project_Referral_Inherit();


                this.ddlDeveloperProvince.Attributes.Add("onchange", "FillCity(this,document.form1.ddlDeveloperCity);");
                this.ddlDeveloperCity.Attributes.Add("onchange", "FillDistrict(this,document.form1.ddlDeveloperDistrict);");
                this.ddlDeveloperDistrict.Attributes.Add("onchange", "FillDistrictType(this,document.form1.ddlDistrictType);");
                this.ddlQqch2.Attributes.Add("onchange", "javascript: if(document.all.ddlQqch2.selectedIndex == 0){ var a = window.prompt('请输入多少天', '0');document.getElementById('txtQqch21').value = a;document.all.ddlQqch2.options[document.all.ddlQqch2.selectedIndex].text = '每月' + a + '日';}");
              
                
                this.ddlSignType.Attributes.Add("onchange", "ddlSingType();");
                string strJS = "window.open('Project_getEmployeeDetail.aspx?fun=getEmployee','','scrollbars=yes,width=720,height=460,status=yes,resizable=yes');return false;";
                this.ibtnMarketing1.Attributes.Add("onclick", strJS);
                //this.DropDownList1.Attributes.Add("onchange", "showHrKD(this)");
                this.ddlProjectState.Attributes.Add("onchange", "changeProjectState(this)");

                ds = Project_Department_Inherit.FindLibrary();
                Common.Common_Function.DropDownListBind(ddlDepartment, ds.Tables[0], "Project_Deparement_ID", "Project_Deparement_Name", "", "--请选择所属部门--");

                ds = Project_SignType_Inherit.FindLibrary();
                Common.Common_Function.DropDownListBind(ddlSignType, ds.Tables[0], "Project_SignType_ID", "Project_SignType_Name", "", "--请选择签署类型--");

                ds = Project_Present_Inherit.FindLibrary();
                Common.Common_Function.DropDownListBind(ddlProjectState, ds.Tables[0], "Project_Present_ID", "Project_Present_Name", "", "--请选择项目现况--");

                ds = Project_Province_Inherit.FindLibrary();
                Common.Common_Function.DropDownListBind(ddlDeveloperProvince, ds.Tables[0], "Province_ID", "Province_Name", "", "--请选择项目现况--");

                ds = Project_ProductType_Inherit.FindLibraryAll();
                Common.Common_Function.CheckBoxListBind(chklProductType, ds.Tables[0], "Project_ProductType_ID", "Project_ProductType_Name");
                Common.Common_Function.DropDownListBind(dropProjectType, ds.Tables[0], "Project_ProductType_ID", "Project_ProductType_Name","");
                Common.Common_Function.DropDownListBind(dropProjectType2, ds.Tables[0], "Project_ProductType_ID", "Project_ProductType_Name", "");

                ds = Project_AgencyType_Inherit.FindLibraryAll();
                CheckBoxNew(chklAgencyType, ds.Tables[0]);

                ds = Project_Encourage1_Inherit.FindLibrary();

            
             

                ds = Project_AccountCycle_Inherit.FindLibrary();
                RadioButtonNew(radlAccountCycle, ds.Tables[0]);

                ds = Project_AccountCondition_Inherit.FindLibrary();
                Common.Common_Function.DropDownListBind(dropCommission, ds.Tables[0], "Project_AccountCondition_ID", "Project_AccountCondition_Name", "");

                ds = Project_BidderAccountCondition_Inherit.FindLibrary();
                CheckBoxNew(chklBidderAccountCondition, ds.Tables[0]);

                ds = Project_SalseAccountCondition_Inherit.FindLibrary();
                RadioButtonNew(radlSalseAccountCondition, ds.Tables[0]);

                ds = Project_Referral_Inherit.FindLibrary();
                Common.Common_Function.DropDownListBind(dropOutComm, ds.Tables[0], "Project_Referral_ID", "Project_Referral_Name", "");
                Common.Common_Function.DropDownListBind(dropReferral, ds.Tables[0], "Project_Referral_ID", "Project_Referral_Name", "");

                this.ibtnMarketing1.Attributes.Add("onclick", "window.open('Project_getEmployeeDetail.aspx?fun=getEmployee_Marketing1','','scrollbars=yes,width=720,height=460,status=yes,resizable=yes');return false;");
                this.ibtnMarketing2.Attributes.Add("onclick", "window.open('Project_getEmployeeDetail.aspx?fun=getEmployee_Marketing2','','scrollbars=yes,width=720,height=460,status=yes,resizable=yes');return false;");
                this.ibtnManager.Attributes.Add("onclick", "window.open('Project_getEmployeeDetail.aspx?fun=getEmployee_Manager','','scrollbars=yes,width=720,height=460,status=yes,resizable=yes');return false;");
                this.ibtnBusiness.Attributes.Add("onclick", "window.open('Project_getEmployeeDetail.aspx?fun=getEmployee_Business','','scrollbars=yes,width=720,height=460,status=yes,resizable=yes');return false;");
                this.ibtnDepartmentHead.Attributes.Add("onclick", "window.open('Project_getEmployeeDetail.aspx?fun=getEmployee_DepartmentHead','','scrollbars=yes,width=720,height=460,status=yes,resizable=yes');return false;");

                #endregion

                if (Request.QueryString["ProjectID"] != null)
                {
                    ViewState["ProjectID"] = Request.QueryString["ProjectID"].ToString();

                    lblTitle.Text = "修改项目";
                    Update_Data_Bind(ViewState["ProjectID"].ToString());
                    this.dgList.Visible = true;
                    BindGrid();
                    this.btnDelete.Visible = true;
                    this.Report_Tab1.Visible = true;
                    this.Report_Tab1.ExchangeTypeID = "11";
                    this.Report_Tab1.MainID = ViewState["ProjectID"].ToString();
                    this.btnReset.Visible = false;
                    this.btnUpLoad.Visible = true;

                    this.btnRenew.Visible = true;
                    this.btnRenew.Attributes.Add("onclick", @"window.open('../EcSalse/Project_Detail.aspx?action=renew&id=" + ViewState["ProjectID"].ToString() + "','','height=1069,width=1057,menubar=no,toolbar=no,location=no,directoris=no,status=yes,resizable=no,scrollbars=yes','fullscreen');");
                }
                else
                {
                    if (Request.QueryString["action"] != null && Request.QueryString["action"] == "renew")
                    {

                        lblTitle.Text = "续约项目";
                        ViewState["ProjectID"] = null;
                        this.btnAudit.Visible = false;

                        Update_Data_Bind(Request.QueryString["id"].ToString());

                        //DataAccess.Operate.DA_Project_Operate Project_Operate = new DataAccess.Operate.DA_Project_Operate();
                        //DataEntity.T_Project entity = (DataEntity.T_Project)Project_Operate.SelectOne(Request.QueryString["id"].ToString());

                        //this.txtProjectName.Text = entity.Project_Name.ToString();
                        //this.txtDeveloper.Text = entity.Project_Developer.ToString();
                        //this.txtSignDate.Text = entity.Project_SignDate.Value.ToString("yyyy-MM-dd");
                        //this.ddlProjectState.SelectedValue = entity.Project_PresentID.ToString();
                        //this.ddlDepartment.SelectedValue = entity.Project_DepartmentID.ToString();
                        //this.ddlSignType.SelectedValue = "2";
                        //this.ddlDeveloperProvince.SelectedValue = entity.Project_DeveloperProvinceID.ToString();
                        //this.txtDeveloperAddress.Text = entity.Project_DeveloperAddress.ToString();
                        //this.txtProject_AvailableArea.Text = entity.Project_AvailableArea.ToString();
                        //this.txtProject_AvailableVolume.Text = entity.Project_AvailableVolume.ToString();


                        //DataAccess.Operate.DA_Project_Hr_Inherit Project_Hr_Inherit = new DataAccess.Operate.DA_Project_Hr_Inherit();
                        //ds = Project_Hr_Inherit.GetFindAllByMainID(entity.Project_ID.ToString());
                        //lstHr.DataSource = ds.Tables[0];
                        //lstHr.DataTextField = "Project_Hr_KDName";
                        //lstHr.DataValueField = "Project_Hr_KDNameID";
                        //lstHr.DataBind();

                        //DataAccess.Operate.DA_Project_City_Inherit Project_City_Inherit = new DataAccess.Operate.DA_Project_City_Inherit();
                        //ds = Project_City_Inherit.FindLibrary(Convert.ToInt32(entity.Project_DeveloperProvinceID.IsNull ? "0" : entity.Project_DeveloperProvinceID.ToString()));
                        //Common.Common_Function.DropDownListBind(ddlDeveloperCity, ds.Tables[0], "City_ID", "City_Name", "", "--城市--");
                        //this.ddlDeveloperCity.SelectedValue = entity.Project_DeveloperCityID.ToString();

                        //DataAccess.Operate.DA_Project_District_Inherit Project_District_Inherit = new DataAccess.Operate.DA_Project_District_Inherit();
                        //ds = Project_District_Inherit.FindLibrary(Convert.ToInt32(entity.Project_DeveloperCityID.IsNull ? "0" : entity.Project_DeveloperCityID.ToString()));
                        //Common.Common_Function.DropDownListBind(ddlDeveloperDistrict, ds.Tables[0], "District_ID", "District_Name", "", "--区--");
                        //this.ddlDeveloperDistrict.SelectedValue = entity.Project_DeveloperDistrictID.ToString();

                        //DataAccess.Operate.DA_Project_DistrictType_Inherit Project_DistrictType_Inherit = new DataAccess.Operate.DA_Project_DistrictType_Inherit();
                        //ds = Project_DistrictType_Inherit.FindLibraryByID(Convert.ToInt32(entity.Project_DeveloperDistrictPropertyID.IsNull ? "0" : entity.Project_DeveloperDistrictPropertyID.ToString()));
                        //Common.Common_Function.DropDownListBind(ddlDistrictType, ds.Tables[0], "Project_DistrictType_ID", "Project_DistrictType_Name", "", "");
                        //this.ddlDistrictType.SelectedValue = entity.Project_DeveloperDistrictPropertyID.ToString();


                    }
                    else
                    {
                        lblTitle.Text = "新增项目";
                        ViewState["ProjectID"] = null;
                        this.btnAudit.Visible = false;
                    }
                }

            }


        }
        #endregion

        #region 保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            try
            {

                DataEntity.T_Project Project = new DataEntity.T_Project();
                DataAccess.Operate.DA_Project_Operate Project_Operate = new DataAccess.Operate.DA_Project_Operate();
                DataAccess.Operate.DA_Project_Inherit Project_Inherit = new DataAccess.Operate.DA_Project_Inherit();

                Guid gProjectID = System.Guid.NewGuid();

                Project.Project_ID = gProjectID;
                Project.Project_Name = this.txtProjectName.Text.Trim();
                Project.Project_SignDate = Convert.ToDateTime(this.txtSignDate.Text.Trim());
                Project.Project_DepartmentID = Convert.ToInt32(this.ddlDepartment.SelectedValue.ToString());
                Project.Project_SignTypeID = Convert.ToInt32(this.ddlSignType.SelectedValue.ToString());
                Project.Project_AgencyDateBegin = this.txtDateStart.Text.Trim();
                Project.Project_AgencyDateEnd = this.txtDateEnd.Text.Trim();
                Project.Project_Developer = this.txtDeveloper.Text.Trim();
                Project.Project_DeveloperProvinceID = Convert.ToInt32(this.ddlDeveloperProvince.SelectedValue.ToString());
                Project.Project_DeveloperAddress = this.txtDeveloperAddress.Text.Trim();
                Project.Project_PresentID = Convert.ToInt32(this.ddlProjectState.SelectedValue.ToString());
                Project.Project_AccountCycle = Convert.ToInt32(this.radlAccountCycle.SelectedValue.ToString());            //结算周期
                Project.Project_AccountCycle_FirstA1 = this.hfldAccountCycle.Value;
                Project.Project_AccountCondition = this.radlSalseAccountCondition.SelectedValue == "" ? 0 : Convert.ToInt32(this.radlSalseAccountCondition.SelectedValue.ToString()); //以完成销售目标为结算条件
                Project.Project_AccountCondition_FirstA1 = this.hfldSalseAccountCondition.Value;

                //Project.Project_OutComm_ID = Convert.ToInt32(radlOutComm.SelectedValue);

                //Project.Project_OutComm_FirstA1 = this.hfldOutComm1.Value;
                ////Project.Project_Referral_ID = this.radlReferral.SelectedValue == "" ? 0 : Convert.ToInt32(radlReferral.SelectedValue);
                //Project.Project_Referral_FirstA1 = this.hfldReferral1.Value;


                if (this.txtProject_AvailableArea.Text.Trim() != "")    //可售面积
                    Project.Project_AvailableArea = Convert.ToDecimal(this.txtProject_AvailableArea.Text.Trim());
                if (this.txtProject_AvailableVolume.Text.Trim() != "")     //可售货量
                    Project.Project_AvailableVolume = Convert.ToDecimal(this.txtProject_AvailableVolume.Text.Trim());
                Project.Project_DirecterCode = this.hfldMarketing1.Value;
                Project.Project_Directer = this.txtMarketing1.Text.Trim();
                Project.Project_Directer1Code = this.hfldMarketing2.Value;
                Project.Project_Directer1 = this.txtMarketing2.Text;
                Project.Project_ManagerCode = this.hfldManager.Value;
                Project.Project_Manager = this.txtManager.Text.Trim();
                Project.Project_Business = this.txtBusiness.Text.Trim();
                Project.Project_BusinessCode = this.hfldBusiness.Value.ToString();
                Project.Project_DepartmentHead = this.txtDepartmentHead.Text.Trim();
                Project.Project_DepartmentHeadCode = this.hfldDepartmentHead.Value.Trim();


                if (ViewState["ProjectID"] == null)
                {
                    Project.Project_Audit = 1;
                    Project.Project_NO = Project_Inherit.genProjectNO();
                    Project.ProjectNOIdx = Project_Inherit.genProjectIndex().ToString();
                    Project.Project_DeveloperCityID = Convert.ToInt32(Request.Form["ddlDeveloperCity"].ToString());
                    Project.Project_DeveloperDistrictID = Convert.ToInt32(Request.Form["ddlDeveloperDistrict"].ToString());
                    Project.Project_DeveloperDistrictPropertyID = Convert.ToInt32(Request.Form["ddlDistrictType"].ToString());
                    Project_Operate.Insert(Project);

                    DataAccess.Multi.System_Multi.addLog(Session["EmployeeID"].ToString(), Session["EmployeeName"].ToString(), 1, gProjectID, 1);

                    #region 上传附件部分
                    DataAccess.Operate.DA_Report_Attach_Operate Report_Attach_Operate = new DataAccess.Operate.DA_Report_Attach_Operate();
                    DataEntity.T_Report_Attach Report_Attach = new DataEntity.T_Report_Attach();
                    string sFileName = "";
                    string sFilePath = "";
                    string sFileType = "";

                    if (!Directory.Exists("\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString()))
                    {
                        Directory.CreateDirectory("\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString());
                    }
                    if (!Directory.Exists("\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString() + "\\" + gProjectID.ToString()))
                    {
                        Directory.CreateDirectory("\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString() + "\\" + gProjectID.ToString());
                    }

                    sFileType = CommonFunction.CheckFileType(this.txtFilePath.PostedFile.FileName);
                    if (sFileType != "")
                    {
                        sFileName = gProjectID.ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + sFileType;
                    }

                    sFilePath = "/ReportManager/" + DateTime.Now.Year + "/" + gProjectID.ToString() + "/" + sFileName;
                    try
                    {
                        Report_Attach.Project_Report_FileDesc = this.txtProjectDesc.Text.Trim();
                        Report_Attach.Project_Report_FileName = sFileName;
                        Report_Attach.Project_Report_FilePath = sFilePath;
                        Report_Attach.Project_Report_ExchangeTypeID = 11;
                        Report_Attach.Project_Report_FileID = Convert.ToInt32(this.ddlFileType.SelectedValue);
                        Report_Attach.Project_Report_MainID = gProjectID;
                        Report_Attach_Operate.Insert(Report_Attach);
                        this.txtFilePath.PostedFile.SaveAs("\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString() + "\\" + gProjectID.ToString() + "\\" + sFileName);
                        DataAccess.Multi.System_Multi.addLog(Session["EmployeeID"].ToString(), Session["EmployeeName"].ToString(), 5, gProjectID, 4);

                    }
                    catch (System.Exception ex)
                    {
                        throw new Exception(ex.Message.ToString());
                    }
                    finally
                    {

                    }

                    #endregion


                }
                else
                {
                    int cityID = 0;
                    int disID = 0;
                    int distypeID = 0;
                    int.TryParse(this.ddlDeveloperCity.SelectedItem.Value, out cityID);
                    Project.Project_DeveloperCityID = cityID;

                    int.TryParse(this.ddlDeveloperDistrict.SelectedItem.Value, out disID);
                    Project.Project_DeveloperDistrictID = disID;

                    int.TryParse(this.ddlDistrictType.SelectedItem.Value, out distypeID);
                    Project.Project_DeveloperDistrictPropertyID = distypeID;

                    Project.Project_ID = new Guid(ViewState["ProjectID"].ToString());

                    Project_Operate.Update(Project);

                    DataAccess.Multi.System_Multi.addLog(Session["EmployeeID"].ToString(), Session["EmployeeName"].ToString(), 1, gProjectID, 2);
                }

                #region 人事树操作部分
                DataAccess.Operate.DA_Project_Hr_Inherit Project_Hr_Inherit = new DataAccess.Operate.DA_Project_Hr_Inherit();
                DataAccess.Operate.DA_Project_Hr_Operate Project_Hr_Operate = new DataAccess.Operate.DA_Project_Hr_Operate();
                DataEntity.T_Project_Hr Project_Hr = new DataEntity.T_Project_Hr();
                Project_Hr.Project_Hr_MainID = gProjectID;
                if (ViewState["ProjectID"] != null)
                {
                    Project_Hr_Inherit.DeleteByMainID(ViewState["ProjectID"].ToString());
                    Project_Hr.Project_Hr_MainID = new Guid(ViewState["ProjectID"].ToString());
                }

                for (int i = 0; i < lstHr.Items.Count; i++)
                {
                    Project_Hr.Project_Hr_KDNameID = new Guid(lstHr.Items[i].Value);
                    Project_Hr.Project_Hr_KDName = lstHr.Items[i].Text;
                    Project_Hr_Operate.Insert(Project_Hr);
                }
                #endregion




                //代理类型
                DataEntity.T_Project_AgencyType Project_AgencyType = new DataEntity.T_Project_AgencyType();
                DataAccess.Operate.DA_Project_AgencyType_Operate Project_AgencyType_Operate = new DataAccess.Operate.DA_Project_AgencyType_Operate();
                Project_AgencyType.Project_AgencyType_MainID = gProjectID;
                if (ViewState["ProjectID"] != null)
                {
                    Project_AgencyType.Project_AgencyType_MainID = new Guid(ViewState["ProjectID"].ToString());
                    DataAccess.Operate.DA_Project_AgencyType_Inherit Project_AgencyType_Inherit = new DataAccess.Operate.DA_Project_AgencyType_Inherit();
                    Project_AgencyType_Inherit.DeleteByMainID(ViewState["ProjectID"].ToString());
                }
                for (int i = 0; i < chklAgencyType.Items.Count; i++)
                {
                    if (chklAgencyType.Items[i].Selected)
                    {
                        Project_AgencyType.Project_AgencyType_TypeID = Convert.ToInt32(chklAgencyType.Items[i].Value.ToString());
                        Project_AgencyType_Operate.Insert(Project_AgencyType);
                    }
                }
                if (!chklAgencyType.Items[3].Selected)   //联动
                {
                    if (ddlSignType.SelectedValue == "3")
                    {
                        Project_AgencyType.Project_AgencyType_TypeID = 4;
                        Project_AgencyType_Operate.Insert(Project_AgencyType);
                    }
                }

                #region 额外奖励
                DataAccess.Operate.DA_Bonuses_Detal_Operate Bonuses_Detal_Operate = new DataAccess.Operate.DA_Bonuses_Detal_Operate();
                DataEntity.T_Bonuses_Detal Bonuses_Detal = new DataEntity.T_Bonuses_Detal();
                Bonuses_Detal.Bonuses_Detal_MainID = gProjectID;
                if (ViewState["ProjectID"] != null)
                {
                    Bonuses_Detal_Operate.DeleteByMainID(ViewState["ProjectID"].ToString());
                    Bonuses_Detal.Bonuses_Detal_MainID = new Guid(ViewState["ProjectID"].ToString());
                }
                if (this.txtBonuses_Detal_Award1.Text.Trim() != "" || this.txtBonuses_Detal_Award2.Text.Trim() != "")
                {
                    Bonuses_Detal.Bonuses_Detal_Award1 = this.txtBonuses_Detal_Award1.Text.Trim();
                    Bonuses_Detal.Bonuses_Detal_Award2 = this.txtBonuses_Detal_Award2.Text.Trim();
                    Bonuses_Detal_Operate.Insert(Bonuses_Detal);
                }
                #endregion

                #region 前期策划部分
                DataEntity.T_Project_EarlyPlot Project_EarlyPlot = new DataEntity.T_Project_EarlyPlot();
                if (chklAgencyType.Items[0].Selected)
                {
                    Project_EarlyPlot.Project_EarlyPlot_MainID = gProjectID;
                    Project_EarlyPlot.Project_EarlyPlot_Fees = Convert.ToDecimal(txtProject_EarlyPlot_Fees.Text.Trim());
                    Project_EarlyPlot.Project_EarlyPlot_FirstA1 = txtQqchA1.Text.Trim();
                    Project_EarlyPlot.Project_EarlyPlot_FirstA2 = Convert.ToInt32(ddlQqchA.SelectedValue.ToString());
                    Project_EarlyPlot.Project_EarlyPlot_FirstA3 = txtQqchA2.Text.Trim();
                    Project_EarlyPlot.Project_EarlyPlot_FirstB1 = txtQqchB1.Text.Trim();
                    Project_EarlyPlot.Project_EarlyPlot_FirstB2 = Convert.ToInt32(ddlQqchB.SelectedValue.ToString());
                    Project_EarlyPlot.Project_EarlyPlot_FirstB3 = txtQqchB2.Text.Trim();
                    Project_EarlyPlot.Project_EarlyPlot_FirstC1 = txtQqchC1.Text.Trim();
                    Project_EarlyPlot.Project_EarlyPlot_FirstC2 = Convert.ToInt32(ddlQqchC.SelectedValue.ToString());
                    Project_EarlyPlot.Project_EarlyPlot_FirstC3 = txtQqchC2.Text.Trim();
                    Project_EarlyPlot.Project_EarlyPlot_FirstD1 = txtQqchD1.Text.Trim();
                    Project_EarlyPlot.Project_EarlyPlot_FirstD2 = Convert.ToInt32(ddlQqchD.SelectedValue.ToString());
                    Project_EarlyPlot.Project_EarlyPlot_FirstD3 = txtQqchD2.Text.Trim();
                    Project_EarlyPlot.Project_EarlyPlot_FirstE1 = txtQqchE1.Text.Trim();
                    Project_EarlyPlot.Project_EarlyPlot_FirstE2 = Convert.ToInt32(ddlQqchE.SelectedValue.ToString());
                    Project_EarlyPlot.Project_EarlyPlot_FirstE3 = txtQqchE2.Text.Trim();

                    Project_EarlyPlot.Project_EarlyPlot_Second1 = txtQqch21.Value;
                    Project_EarlyPlot.Project_EarlyPlot_Second2 = Convert.ToInt32(ddlQqch2.SelectedValue.ToString());
                    Project_EarlyPlot.Project_EarlyPlot_Second3 = txtQqch22.Text.Trim();

                    DataAccess.Operate.DA_Project_EarlyPlot_Operate Project_EarlyPlot_Operate = new DataAccess.Operate.DA_Project_EarlyPlot_Operate();
                    DataAccess.Operate.DA_Project_EarlyPlot_Inherit Project_EarlyPlot_Inherit = new DataAccess.Operate.DA_Project_EarlyPlot_Inherit();

                    if (ViewState["ProjectID"] != null)
                    {
                        Project_EarlyPlot.Project_EarlyPlot_MainID = new Guid(ViewState["ProjectID"].ToString());
                        Project_EarlyPlot_Inherit.DeleteByMainID(ViewState["ProjectID"].ToString());
                        Project_EarlyPlot_Operate.Insert(Project_EarlyPlot);


                    }
                    else
                    {
                        Project_EarlyPlot_Operate.Insert(Project_EarlyPlot);
                    }
                }
                #endregion

                #region 销售独立代理
                if (this.chklAgencyType.Items[1].Selected)
                {
                    DataAccess.Operate.DA_SalesAgent_Detal_Operate SalesAgent_Detal_Operate = new DataAccess.Operate.DA_SalesAgent_Detal_Operate();
                    DataEntity.T_SalesAgent_Detal SalesAgent_Detal = new DataEntity.T_SalesAgent_Detal();
                    SalesAgent_Detal.SalesAgent_Detal_MainID=gProjectID;
                    if (ViewState["ProjectID"] != null)
                    {
                        SalesAgent_Detal_Operate.DeleteByMainID(ViewState["ProjectID"].ToString());
                        SalesAgent_Detal.SalesAgent_Detal_MainID = new Guid(ViewState["ProjectID"].ToString());
                    }
                    SalesAgent_Detal.SalesAgent_Detal_Alone = this.txtSalesAgent_Detal_Alone.Text.Trim();
                    SalesAgent_Detal.SalesAgent_Detal_Developer = this.txtSalesAgent_Detal_Developer.Text.Trim();
                    SalesAgent_Detal_Operate.Insert(SalesAgent_Detal);

                }
                #endregion

                #region 招租部分
                if (this.chklAgencyType.Items[2].Selected == true)
                {
                    DataAccess.Operate.DA_LeaseAgent_Detal_Operate LeaseAgent_Detal_Operate = new DataAccess.Operate.DA_LeaseAgent_Detal_Operate();
                    DataEntity.T_LeaseAgent_Detal LeaseAgent_Detal = new DataEntity.T_LeaseAgent_Detal();
                    LeaseAgent_Detal.LeaseAgent_Detal_MainID = gProjectID;
                    if (ViewState["ProjectID"] != null)
                    {
                        LeaseAgent_Detal_Operate.DeleteByMainID(ViewState["ProjectID"].ToString());
                        LeaseAgent_Detal.LeaseAgent_Detal_MainID =new Guid(ViewState["ProjectID"].ToString());
                    }
                    LeaseAgent_Detal.LeaseAgent_Detal_Central = this.txtLeaseAgent_Detal_Central.Text.Trim();
                    LeaseAgent_Detal.LeaseAgent_Detal_Developer = this.txtLeaseAgent_Detal_Developer.Text.Trim();
                    LeaseAgent_Detal_Operate.Insert(LeaseAgent_Detal);
                }
                #endregion

                #region 联动部分
                if (ddlSignType.SelectedValue == "3" || this.chklAgencyType.Items[3].Selected)
                {
                    DataAccess.Operate.DA_LinkAgent_Detal_Operate LinkAgent_Detal_Operate = new DataAccess.Operate.DA_LinkAgent_Detal_Operate();
                    DataEntity.T_LinkAgent_Detal LinkAgent_Detal = new DataEntity.T_LinkAgent_Detal();
                    LinkAgent_Detal.LinkAgent_Detal_MainID = gProjectID;
                    if (ViewState["ProjectID"] != null)
                    {
                        LinkAgent_Detal_Operate.DeleteByMainID(ViewState["ProjectID"].ToString());
                        LinkAgent_Detal.LinkAgent_Detal_MainID = new Guid(ViewState["ProjectID"].ToString());
                    }
                    LinkAgent_Detal.LinkAgent_Detal_Link = this.txtLinkAgent_Detal_Link.Text.Trim();
                    LinkAgent_Detal.LinkAgent_Detal_Developer = this.txtLinkAgent_Detal_Developer.Text.Trim();
                    LinkAgent_Detal_Operate.Insert(LinkAgent_Detal);
                }
                #endregion


                //产品类型
                DataEntity.T_Project_ProductType Project_ProductType = new DataEntity.T_Project_ProductType();
                DataAccess.Operate.DA_Project_ProductType_Inherit Project_ProductType_Inherit = new DataAccess.Operate.DA_Project_ProductType_Inherit();
                DataAccess.Operate.DA_Project_ProductType_Operate Project_ProductType_Operate = new DataAccess.Operate.DA_Project_ProductType_Operate();
                Project_ProductType.Project_ProductType_MainID = gProjectID;
                if (ViewState["ProjectID"] != null)
                {
                    Project_ProductType.Project_ProductType_MainID = new Guid(ViewState["ProjectID"].ToString());
                    Project_ProductType_Inherit.DeleteByID(ViewState["ProjectID"].ToString());
                }
                for (int i = 0; i < chklProductType.Items.Count; i++)
                {
                    if (chklProductType.Items[i].Selected)
                    {
                        Project_ProductType.Project_ProductType_TypeID = Convert.ToInt32(chklProductType.Items[i].Value);
                        Project_ProductType_Operate.Insert(Project_ProductType);
                    }
                }

                //当期报数点数
                //DataEntity.T_Project_Point Project_Point = new DataEntity.T_Project_Point();
                //DataAccess.Operate.DA_Project_Point_Operate Project_Point_Operate = new DataAccess.Operate.DA_Project_Point_Operate();
                //Project_Point.Project_Point_MainID = gProjectID;
                //if (ViewState["ProjectID"] != null)
                //{
                //    DataAccess.Operate.DA_Project_Point_Inherit Project_Point_Inherit = new DataAccess.Operate.DA_Project_Point_Inherit();
                //    Project_Point_Inherit.DeleteByMainID(ViewState["ProjectID"].ToString());
                //    Project_Point.Project_Point_MainID = new Guid(ViewState["ProjectID"].ToString());
                //}
                //Project_Point.Project_Point_FirstA1 = txtPoint1.Text.Trim();
                //Project_Point.Project_Point_SecondA1 = Convert.ToInt32(ddlPoint.SelectedValue.ToString());

                //Project_Point.Project_Point_ThirdA1 = txtPoint31.Text.Trim();
                //Project_Point.Project_Point_ThirdA2 = txtPoint32.Text.Trim();
                //Project_Point_Operate.Insert(Project_Point);



                //以买家付款进度为结算条件
                DataEntity.T_Project_BidderAccountCondition Project_BidderAccountCondition = new DataEntity.T_Project_BidderAccountCondition();
                DataAccess.Operate.DA_Project_BidderAccountCondition_Operate Project_BidderAccountCondition_Operate = new DataAccess.Operate.DA_Project_BidderAccountCondition_Operate();
                Project_BidderAccountCondition.Project_BidderAccountCondition_MainID = gProjectID;
                if (ViewState["ProjectID"] != null)
                {
                    DataAccess.Operate.DA_Project_BidderAccountCondition_Inherit Project_BidderAccountCondition_Inherit = new DataAccess.Operate.DA_Project_BidderAccountCondition_Inherit();
                    Project_BidderAccountCondition_Inherit.DeleteByMainID(ViewState["ProjectID"].ToString());
                    Project_BidderAccountCondition.Project_BidderAccountCondition_MainID = new Guid(ViewState["ProjectID"].ToString());
                }
                for (int i = 0; i < chklBidderAccountCondition.Items.Count; i++)
                {
                    if (chklBidderAccountCondition.Items[i].Selected)
                    {
                        Project_BidderAccountCondition.Project_BidderAccountCondition_BidderAccountConditionID = Convert.ToInt32(chklBidderAccountCondition.Items[i].Value);
                        Project_BidderAccountCondition_Operate.Insert(Project_BidderAccountCondition);
                    }
                }

                //收佣条件
                DataAccess.Operate.DA_Project_CommissionConditions_Operate Project_CommissionConditions_Operate = new DataAccess.Operate.DA_Project_CommissionConditions_Operate();
                DataEntity.T_Project_CommissionConditions Project_CommissionConditions = new DataEntity.T_Project_CommissionConditions();
                Project_CommissionConditions.Project_CommissionConditions_MainID = gProjectID;
                if (ViewState["ProjectID"] != null)
                {
                    Project_CommissionConditions_Operate.Delete(ViewState["ProjectID"].ToString());
                    Project_CommissionConditions.Project_CommissionConditions_MainID =new Guid(ViewState["ProjectID"].ToString());
                }
           
                if (this.hfldCommission.Value != "")
                {
                    this.hfldCommission.Value = this.hfldCommission.Value.Substring(0, this.hfldCommission.Value.Length - 1);
                    string[] entitys = this.hfldCommission.Value.Split('|');
                    for (int i = 0; i < entitys.Length; i++)
                    {
                        string[] entity = entitys[i].Split(',');
                        Project_CommissionConditions.Project_CommissionConditions_Type =Convert.ToInt32(entity[0]);
                        Project_CommissionConditions.Project_CommissionConditions_DayNumber = Convert.ToInt32(entity[1]);
                        Project_CommissionConditions.Project_CommissionConditions_DayType = Convert.ToInt32(entity[2]);
                        Project_CommissionConditions.Project_CommissionConditions_Tally = Convert.ToDecimal(entity[3]);
                        Project_CommissionConditions_Operate.Insert(Project_CommissionConditions);
                    }
                }

                //对外收佣
                DataAccess.Operate.DA_Project_OutComm_Operate Project_OutComm_Operate = new DataAccess.Operate.DA_Project_OutComm_Operate();
                DataEntity.T_Project_OutComm Project_OutComm = new DataEntity.T_Project_OutComm();
                Project_OutComm.Project_OutComm_MainID = gProjectID;
                if (ViewState["ProjectID"] != null)
                {
                    Project_OutComm_Operate.Delete(ViewState["ProjectID"].ToString());
                    Project_OutComm.Project_OutComm_MainID = new Guid(ViewState["ProjectID"].ToString());
                }
                if (hfldOutComm.Value != "")
                {
                    this.hfldOutComm.Value = this.hfldOutComm.Value.Substring(0, this.hfldOutComm.Value.Length - 1);
                    string[] entitys=this.hfldOutComm.Value.Split('|');
                    for (int i = 0; i < entitys.Length; i++)
                    { 
                        string[] entity=entitys[i].Split(',');
                        Project_OutComm.Project_OutComm_Type =Convert.ToInt32(entity[0]);
                        Project_OutComm.Project_OutComm_Tally = Convert.ToDecimal(entity[1]);
                        Project_OutComm_Operate.Insert(Project_OutComm);
                    }
                }


                //转介盘源转介费
                DataAccess.Operate.DA_Project_Referral_Operate Project_Referral_Operate = new DataAccess.Operate.DA_Project_Referral_Operate();
                DataEntity.T_Project_Referral Project_Referral = new DataEntity.T_Project_Referral();
                Project_Referral.Project_Referral_MainID = gProjectID;
                if (ViewState["ProjectID"] != null)
                {
                    Project_Referral_Operate.Delete(ViewState["ProjectID"].ToString());
                    Project_Referral.Project_Referral_MainID = new Guid(ViewState["ProjectID"].ToString());
                }
                if (hfldReferral.Value != "")
                {
                    this.hfldReferral.Value = this.hfldReferral.Value.Substring(0, this.hfldReferral.Value.Length - 1);
                    string[] entitys=this.hfldReferral.Value.Split('|');
                    for (int i = 0; i < entitys.Length; i++)
                    {
                        string[] entity = entitys[i].Split(',');
                        Project_Referral.Project_Referral_Type = Convert.ToInt32(entity[0]);
                        Project_Referral.Project_Referral_Tally = Convert.ToDecimal(entity[1]);
                        Project_Referral_Operate.Insert(Project_Referral);
                    }
                }


                if (ViewState["ProjectID"] == null)
                {
                    string sTemp = "项目编号:" + Project.Project_NO.ToString() + "-新增成功!";
                    this.Page.ClientScript.RegisterStartupScript(typeof(Page), "", "<script>alert('" + sTemp + "');window.close();</script>");
                    //提醒营销[副]总监审批
                    SendMessage("5", gProjectID.ToString());
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(typeof(Page), "", "<script>alert('修改成功');window.close();</script>");
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('" + ex.Message + "');</script>");
            }

        }
        #endregion

        #region 修改时数据绑定
        private void Update_Data_Bind(string sProjectID)
        {
            DataSet ds = new DataSet();
            DataEntity.T_Project Project = new DataEntity.T_Project();

            DataEntity.T_Project_AgencyType Project_AgencyType = new DataEntity.T_Project_AgencyType();
            DataAccess.Operate.DA_Project_Operate Project_Operate = new DataAccess.Operate.DA_Project_Operate();
            DataAccess.Operate.DA_Project_AgencyType_Operate Project_AgencyType_Operate = new DataAccess.Operate.DA_Project_AgencyType_Operate();
            DataAccess.Operate.DA_Project_AgencyType_Inherit Project_AgencyType_Inherit = new DataAccess.Operate.DA_Project_AgencyType_Inherit();
            DataAccess.Operate.DA_Project_Province_Inherit Project_Province_Inherit = new DataAccess.Operate.DA_Project_Province_Inherit();
            DataAccess.Operate.DA_Project_City_Inherit Project_City_Inherit = new DataAccess.Operate.DA_Project_City_Inherit();
            DataAccess.Operate.DA_Project_District_Inherit Project_District_Inherit = new DataAccess.Operate.DA_Project_District_Inherit();
            DataAccess.Operate.DA_Project_DistrictType_Inherit Project_DistrictType_Inherit = new DataAccess.Operate.DA_Project_DistrictType_Inherit();

            Project = (DataEntity.T_Project)Project_Operate.SelectOne(sProjectID);
            if (Project.Project_Audit > 1)
            {
                this.btnSubmit.Enabled = false;
                this.btnDelete.Enabled = false;
            }
            if (Project.Project_Audit == 2)
                this.btnAudit.Text = "营销[副]总监审核";
            if (Project.Project_Audit == 3)
                this.btnAudit.Text = "部门负责人审核";
            if (Project.Project_Audit == 4)
                this.btnAudit.Text = "系统管理员审核";
            if (Project.Project_Audit == 5)
            {
                this.btnAudit.Text = "审核已完成";
                this.btnAudit.Enabled = false;
            }

            if (!CommonFunction.isInPrev("Project_Deal_0005") && this.btnAudit.Text == "营销[副]总监审核")
            {
                this.btnAudit.Enabled = false;  //营销副总监
            }
            if (!CommonFunction.isInPrev("Project_Deal_0006") && this.btnAudit.Text == "部门负责人审核")
            {
                this.btnAudit.Enabled = false; //部门负责人
            }
            if (!CommonFunction.isInPrev("Project_Deal_0007") && this.btnAudit.Text == "系统管理员审核")
            {
                this.btnAudit.Enabled = false; //系统管理员
            }

            if (!Project.Project_ID.IsNull)
            {
                this.txtProjectName.Text = Project.Project_Name.IsNull ? "" : Project.Project_Name.ToString();
                this.txtDeveloper.Text = Project.Project_Developer.IsNull ? "" : Project.Project_Developer.ToString();
                this.txtSignDate.Text = Project.Project_SignDate.IsNull ? "" : Project.Project_SignDate.Value.ToString("yyyy-MM-dd");
                this.txtManager.Text = Project.Project_Manager.ToString();
                this.hfldManager.Value = Project.Project_ManagerCode.ToString();
                this.txtMarketing1.Text = Project.Project_Directer.ToString();
                this.hfldMarketing1.Value = Project.Project_DirecterCode.ToString();
                this.txtMarketing2.Text = Project.Project_Directer1.ToString();
                this.hfldMarketing2.Value = Project.Project_Directer1Code.ToString();
                this.txtBusiness.Text = Project.Project_Business.ToString();
                this.hfldBusiness.Value = Project.Project_BusinessCode.ToString();
                this.txtDepartmentHead.Text = Project.Project_DepartmentHead.ToString();
                this.hfldDepartmentHead.Value = Project.Project_DepartmentHeadCode.ToString();

                DataAccess.Operate.DA_Project_Hr_Inherit Project_Hr_Inherit = new DataAccess.Operate.DA_Project_Hr_Inherit();
                ds = Project_Hr_Inherit.GetFindAllByMainID(sProjectID);
                lstHr.DataSource = ds.Tables[0];
                lstHr.DataTextField = "Project_Hr_KDName";
                lstHr.DataValueField = "Project_Hr_KDNameID";
                lstHr.DataBind();

                this.ddlSignType.SelectedValue = Project.Project_SignTypeID.IsNull ? "" : Project.Project_SignTypeID.ToString();
                //this.ddlDeveloperProvince.Text = Project.Project_DeveloperProvinceID.IsNull ? "" : Project.Project_DeveloperProvinceID.ToString();
                //this.ddlDeveloperCity.Text = Project.Project_DeveloperCityID.IsNull ? "" : Project.Project_DeveloperCityID.ToString();
                //this.ddlDeveloperDistrict.Text = Project.Project_DeveloperDistrictID.IsNull ? "" : Project.Project_DeveloperDistrictID.ToString();
                this.txtDeveloperAddress.Text = Project.Project_DeveloperAddress.IsNull ? "" : Project.Project_DeveloperAddress.ToString();
                this.ddlDistrictType.Text = Project.Project_DeveloperDistrictPropertyID.IsNull ? "" : Project.Project_DeveloperDistrictPropertyID.ToString();
                this.ddlDepartment.Text = Project.Project_DepartmentID.IsNull ? "" : Project.Project_DepartmentID.ToString();
                this.ddlProjectState.Text = Project.Project_PresentID.IsNull ? "" : Project.Project_PresentID.ToString();
                this.txtDateStart.Text = Project.Project_AgencyDateBegin.ToString();
                this.txtDateEnd.Text = Project.Project_AgencyDateEnd.ToString();
                this.txtProject_AvailableArea.Text = Project.Project_AvailableArea.IsNull ? "" : Project.Project_AvailableArea.ToString();
                this.txtProject_AvailableVolume.Text = Project.Project_AvailableVolume.IsNull?"":Project.Project_AvailableVolume.ToString();
    
                //结算周期
                radlAccountCycle.SelectedValue = Project.Project_AccountCycle.ToString();
                if (radlAccountCycle.SelectedValue == "3")
                    radlAccountCycle.Items[2].Text = "每月" + Project.Project_AccountCycle_FirstA1.ToString() + "日";

                //完成销售目标作为结算条件
                radlSalseAccountCondition.SelectedValue = Project.Project_AccountCondition.ToString();
                if (radlSalseAccountCondition.SelectedValue == "1")
                    radlSalseAccountCondition.Items[0].Text = "达到首个销售目标(" + Project.Project_AccountCondition_FirstA1.ToString() + ")";
                else if (radlSalseAccountCondition.SelectedValue == "2")
                    radlSalseAccountCondition.Items[1].Text = "达到第二个销售目标(" + Project.Project_AccountCondition_FirstA1.ToString() + ")";
                else if (radlSalseAccountCondition.SelectedValue == "3")
                    radlSalseAccountCondition.Items[2].Text = "达到第三个销售目标(" + Project.Project_AccountCondition_FirstA1.ToString() + ")";
                else if (radlSalseAccountCondition.SelectedValue == "4")
                    radlSalseAccountCondition.Items[3].Text = "达到第四个销售目标(" + Project.Project_AccountCondition_FirstA1.ToString() + ")";
                else if (radlSalseAccountCondition.SelectedValue == "5")
                    radlSalseAccountCondition.Items[4].Text = "达到第五个销售目标(" + Project.Project_AccountCondition_FirstA1.ToString() + ")";
                else if (radlSalseAccountCondition.SelectedValue == "6")
                    radlSalseAccountCondition.Items[5].Text = "完成年度销售目标(" + Project.Project_AccountCondition_FirstA1.ToString() + ")";


                ds = Project_Province_Inherit.FindLibrary();
                Common.Common_Function.DropDownListBind(ddlDeveloperProvince, ds.Tables[0], "Province_ID", "Province_Name", "", "--请选择项目现况--");
                this.ddlDeveloperProvince.SelectedValue = Project.Project_DeveloperProvinceID.IsNull ? "0" : Project.Project_DeveloperProvinceID.ToString();


                ds = Project_City_Inherit.FindLibrary(Convert.ToInt32(Project.Project_DeveloperProvinceID.IsNull ? "0" : Project.Project_DeveloperProvinceID.ToString()));
                Common.Common_Function.DropDownListBind(ddlDeveloperCity, ds.Tables[0], "City_ID", "City_Name", "", "--城市--");
                this.ddlDeveloperCity.SelectedValue = Project.Project_DeveloperCityID.IsNull ? "0" : Project.Project_DeveloperCityID.ToString();

                ds = Project_District_Inherit.FindLibrary(Convert.ToInt32(Project.Project_DeveloperCityID.IsNull ? "0" : Project.Project_DeveloperCityID.ToString()));
                Common.Common_Function.DropDownListBind(ddlDeveloperDistrict, ds.Tables[0], "District_ID", "District_Name", "", "--区--");
                this.ddlDeveloperDistrict.SelectedValue = Project.Project_DeveloperDistrictID.IsNull ? "0" : Project.Project_DeveloperDistrictID.ToString();

                ds = Project_DistrictType_Inherit.FindLibraryByID(Convert.ToInt32(Project.Project_DeveloperDistrictPropertyID.IsNull ? "0" : Project.Project_DeveloperDistrictPropertyID.ToString()));
                Common.Common_Function.DropDownListBind(ddlDistrictType, ds.Tables[0], "Project_DistrictType_ID", "Project_DistrictType_Name", "", "");
                this.ddlDistrictType.SelectedValue = Project.Project_DeveloperDistrictPropertyID.IsNull ? "0" : Project.Project_DeveloperDistrictPropertyID.ToString();



                #region 产品类型
                DataAccess.Operate.DA_Project_ProductType_Inherit Project_ProductType_Inherit = new DataAccess.Operate.DA_Project_ProductType_Inherit();
                ds = Project_ProductType_Inherit.FindProjectAllByID(sProjectID);
                if (ds.Tables[0] != null)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        for (int j = 0; j < chklProductType.Items.Count; j++)
                        {
                            if (chklProductType.Items[j].Value == ds.Tables[0].Rows[i]["Project_ProductType_TypeID"].ToString())
                            {
                                chklProductType.Items[j].Selected = true;
                            }
                        }
                    }
                }
                #endregion

                #region 代理类型

                ds = Project_AgencyType_Inherit.FindProjectAllByID(sProjectID);
                if (ds.Tables[0] != null)
                {

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        for (int j = 0; j < this.chklAgencyType.Items.Count; j++)
                        {
                            if (chklAgencyType.Items[j].Value == ds.Tables[0].Rows[i][0].ToString())
                            {
                                chklAgencyType.Items[j].Selected = true;
                            }
                        }

                    }
                }
                #endregion


                #region 收佣条件
                DataAccess.Operate.DA_Project_AccountCondition_Inherit Project_AccountCondition_Inherit = new DataAccess.Operate.DA_Project_AccountCondition_Inherit();
                DataAccess.Operate.DA_Project_CommissionConditions_Operate Project_CommissionConditions_Operate = new DataAccess.Operate.DA_Project_CommissionConditions_Operate();
                DataTable table = Project_CommissionConditions_Operate.SelectAllByMainID(sProjectID);
                string strHtml = "";
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    string strType =table.Rows[i]["Project_CommissionConditions_Type"].ToString();
                    string strTypeText = Project_AccountCondition_Inherit.GetDicNameByID(Convert.ToInt32(table.Rows[i]["Project_CommissionConditions_Type"]));
                    string strDayNumber = table.Rows[i]["Project_CommissionConditions_DayNumber"].ToString();
                    string strDayType = table.Rows[i]["Project_CommissionConditions_DayType"].ToString();
                    string strDayTypeText = strDayType == "1" ? "天" : "工作天";
                    string strTally = table.Rows[i]["Project_CommissionConditions_Tally"].ToString();
                    strHtml = "var div=document.createElement('div');div.innerHTML='" + strTypeText + strDayNumber + strDayTypeText + "内,支付" + strTally + "%&nbsp;&nbsp;<a onclick=\"DelArea(&quot;CommissionArea&quot;,this.parentNode,&quot;"+i+"&quot;)\" style=\"cursor:pointer;\"><image  src=\"../images/delete.gif\" /></a>';document.getElementById('CommissionArea').appendChild(div);";
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "Commissionscript" + i, "<script>" + strHtml + "</script> ");
                    this.hfldCommission.Value += strType + "," + strDayNumber + "," + strDayType + "," + strTally + "|";
                }
                #endregion

                DataAccess.Operate.DA_Project_OutComm_Operate Project_OutComm_Operate = new DataAccess.Operate.DA_Project_OutComm_Operate();
                DataEntity.T_Project_OutComm Project_OutComm = new DataEntity.T_Project_OutComm();
                table = Project_OutComm_Operate.SelectAllByMainID(sProjectID);
                strHtml = "";
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    string strType = table.Rows[i]["Project_OutComm_Type"].ToString();
                    string strTally = table.Rows[i]["Project_OutComm_Tally"].ToString();
                    string strTypeText = "";
                    switch (strType)
                    {
                        case "1":
                            strTypeText = "一次性支付" + strTally + "元";
                            break;
                        case"2":
                            strTypeText = "按中原实收佣金"+strTally+"%计提（含税）";
                            break;
                        case"3":
                            strTypeText = "按中原成交金额" + strTally + "%计提（含税）";
                            break;
                    }

                    strHtml = "var div=document.createElement('div');div.innerHTML='" + strTypeText + "&nbsp;&nbsp;<a onclick=\"DelArea(&quot;OutCommArea&quot;,this.parentNode,&quot;" + i + "&quot;)\" style=\"cursor:pointer;\"><image  src=\"../images/delete.gif\" /></a>';document.getElementById('OutCommArea').appendChild(div);";
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "OutCommScript"+i, "<script>" + strHtml + "</script>");
                    this.hfldOutComm.Value += strType + "," + strTally + "|";
                }

                DataAccess.Operate.DA_Project_Referral_Operate Project_Referral_Operate = new DataAccess.Operate.DA_Project_Referral_Operate();
                DataEntity.T_Project_Referral Project_Referral = new DataEntity.T_Project_Referral();
                table = Project_Referral_Operate.SelectAllByMainID(sProjectID);
                strHtml = "";
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    string strType = table.Rows[i]["Project_Referral_Type"].ToString();
                    string strTally = table.Rows[i]["Project_Referral_Tally"].ToString();
                    string strTypeText = "";
                    switch (strType)
                    {
                        case "1":
                            strTypeText = "一次性支付" + strTally + "元";
                            break;
                        case "2":
                            strTypeText = "按中原实收佣金" + strTally + "%计提（含税）";
                            break;
                        case "3":
                            strTypeText = "按中原成交金额" + strTally + "%计提（含税）";
                            break;
                    }
                    strHtml = "var div=document.createElement('div');div.innerHTML='" + strTypeText + "&nbsp;&nbsp;<a onclick=\"DelArea(&quot;ReferralArea&quot;,this.parentNode,&quot;" + i + "&quot;)\" style=\"cursor:pointer;\"><image  src=\"../images/delete.gif\" /></a>';document.getElementById('ReferralArea').appendChild(div);";
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "ReferralScript" + i, "<script>" + strHtml + "</script>");
                    this.hfldReferral.Value += strType + "," + strTally + "|";
                }

                //额外奖励
                DataAccess.Operate.DA_Bonuses_Detal_Operate Bonuses_Detal_Operate = new DataAccess.Operate.DA_Bonuses_Detal_Operate();
                DataEntity.T_Bonuses_Detal Bonuses_Detal = (DataEntity.T_Bonuses_Detal)Bonuses_Detal_Operate.SelectOneByMainID(sProjectID);
                if (Bonuses_Detal != null)
                {
                    this.txtBonuses_Detal_Award1.Text = Bonuses_Detal.Bonuses_Detal_Award1.ToString();
                    this.txtBonuses_Detal_Award2.Text = Bonuses_Detal.Bonuses_Detal_Award2.ToString();
                }

                #region 
                if (this.chklAgencyType.Items[0].Selected)
                {
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "EarlyPlotscript", "<script>document.getElementById('lk2').style.display='inline-block';</script> ");
                    DataAccess.Operate.DA_Project_EarlyPlot_Inherit Project_EarlyPlot_Inherit = new DataAccess.Operate.DA_Project_EarlyPlot_Inherit();
                    DataEntity.T_Project_EarlyPlot Project_EarlyPlot = (DataEntity.T_Project_EarlyPlot)Project_EarlyPlot_Inherit.SelectOneByMainID(sProjectID);
                    txtQqchA1.Text = Project_EarlyPlot.Project_EarlyPlot_FirstA1.ToString();
                    ddlQqchA.SelectedValue = Project_EarlyPlot.Project_EarlyPlot_FirstA2.ToString();
                    txtQqchA2.Text = Project_EarlyPlot.Project_EarlyPlot_FirstA3.ToString();
                    txtQqchB1.Text = Project_EarlyPlot.Project_EarlyPlot_FirstB1.ToString();
                    ddlQqchB.SelectedValue = Project_EarlyPlot.Project_EarlyPlot_FirstB2.ToString();
                    txtQqchB2.Text = Project_EarlyPlot.Project_EarlyPlot_FirstB3.ToString();
                    txtQqchC1.Text = Project_EarlyPlot.Project_EarlyPlot_FirstC1.ToString();
                    ddlQqchC.SelectedValue = Project_EarlyPlot.Project_EarlyPlot_FirstC2.ToString();
                    txtQqchC2.Text = Project_EarlyPlot.Project_EarlyPlot_FirstC3.ToString();
                    txtQqchD1.Text = Project_EarlyPlot.Project_EarlyPlot_FirstD1.ToString();
                    ddlQqchD.SelectedValue = Project_EarlyPlot.Project_EarlyPlot_FirstD2.ToString();
                    txtQqchD2.Text = Project_EarlyPlot.Project_EarlyPlot_FirstD3.ToString();
                    txtQqchE1.Text = Project_EarlyPlot.Project_EarlyPlot_FirstE1.ToString();
                    ddlQqchE.SelectedValue = Project_EarlyPlot.Project_EarlyPlot_FirstE2.ToString();
                    txtQqchE2.Text = Project_EarlyPlot.Project_EarlyPlot_FirstE3.ToString();
                    this.txtProject_EarlyPlot_Fees.Text = Project_EarlyPlot.Project_EarlyPlot_Fees.ToString();
                    txtQqch21.Value = Project_EarlyPlot.Project_EarlyPlot_Second1.ToString();
                    if (txtQqch21.Value != "")
                    {
                        ddlQqch2.Items[0].Text = "每月" + txtQqch21.Value + "日";
                    }
                    ddlQqch2.SelectedValue = Project_EarlyPlot.Project_EarlyPlot_Second2.ToString();
                    txtQqch22.Text = Project_EarlyPlot.Project_EarlyPlot_Second3.ToString();

                }
                if (this.chklAgencyType.Items[1].Selected)
                {
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "SalseAgencyscript", "<script>document.getElementById('lk3').style.display='inline-block';</script> ");
                    DataAccess.Operate.DA_SalesAgent_Detal_Operate SalesAgent_Detal_Operate = new DataAccess.Operate.DA_SalesAgent_Detal_Operate();
                    DataEntity.T_SalesAgent_Detal SalesAgent_Detal = (DataEntity.T_SalesAgent_Detal)SalesAgent_Detal_Operate.SelectOneByMainID(sProjectID);
                    this.txtSalesAgent_Detal_Alone.Text = SalesAgent_Detal.SalesAgent_Detal_Alone.ToString();
                    this.txtSalesAgent_Detal_Developer.Text = SalesAgent_Detal.SalesAgent_Detal_Developer.ToString();

          
                }
                if (this.chklAgencyType.Items[2].Selected)
                {
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "Leasescript", "<script>document.getElementById('lk4').style.display='inline-block';</script> ");
                    DataAccess.Operate.DA_LeaseAgent_Detal_Operate LeaseAgent_Detal_Operate = new DataAccess.Operate.DA_LeaseAgent_Detal_Operate();
                    DataEntity.T_LeaseAgent_Detal LeaseAgent_Detal = (DataEntity.T_LeaseAgent_Detal)LeaseAgent_Detal_Operate.SelectOneByMainID(sProjectID);
                    this.txtLeaseAgent_Detal_Central.Text = LeaseAgent_Detal.LeaseAgent_Detal_Central.ToString();
                    this.txtLeaseAgent_Detal_Developer.Text = LeaseAgent_Detal.LeaseAgent_Detal_Developer.ToString();
             
                }
                if (this.chklAgencyType.Items[3].Selected || this.ddlSignType.SelectedValue == "3")
                {
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "UnionCommscript", "<script>document.getElementById('lk5').style.display='inline-block';</script> ");
                    DataAccess.Operate.DA_LinkAgent_Detal_Operate LinkAgent_Detal_Operate = new DataAccess.Operate.DA_LinkAgent_Detal_Operate();
                    DataEntity.T_LinkAgent_Detal LinkAgent_Detal = (DataEntity.T_LinkAgent_Detal)LinkAgent_Detal_Operate.SelectOneByMainID(sProjectID);
                    this.txtLinkAgent_Detal_Link.Text = LinkAgent_Detal.LinkAgent_Detal_Link.ToString();
                    this.txtLinkAgent_Detal_Developer.Text = LinkAgent_Detal.LinkAgent_Detal_Developer.ToString();
                }
                #endregion

                #region 当前报数部分
                //DataAccess.Operate.DA_Project_Point_Inherit Project_Point_Inherit = new DataAccess.Operate.DA_Project_Point_Inherit();
                //DataEntity.T_Project_Point Project_Point = Project_Point_Inherit.SelectOne(sProjectID);
                //txtPoint1.Text = Project_Point.Project_Point_FirstA1.ToString();
                //ddlPoint.SelectedValue = Project_Point.Project_Point_SecondA1.ToString();
                //ddlPoint.Items[1].Text = "月均租金的" + Project_Point.Project_Point_SecondA2.ToString() + "倍计提";
                //txtPoint31.Text = Project_Point.Project_Point_ThirdA1.ToString();
                //txtPoint32.Text = Project_Point.Project_Point_ThirdA2.ToString();
                #endregion

    

                #region 以买家付款进度作为结算条件部分
                DataAccess.Operate.DA_Project_BidderAccountCondition_Inherit BidderAccountCondition_Inherit = new DataAccess.Operate.DA_Project_BidderAccountCondition_Inherit();
                ds = BidderAccountCondition_Inherit.FindByMainID(sProjectID);
                for (int i = 0; i < chklBidderAccountCondition.Items.Count; i++)
                {
                    for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                    {
                        if (chklBidderAccountCondition.Items[i].Value == ds.Tables[0].Rows[j][2].ToString())
                        {
                            chklBidderAccountCondition.Items[i].Selected = true;
                        }
                    }
                }

                #endregion

                

            }


        }
        #endregion

        #region   删除项目操作
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            string ID = ViewState["ProjectID"].ToString();
            DataAccess.Operate.DA_Project_Operate Project_Operate = new DataAccess.Operate.DA_Project_Operate();
            if (Project_Operate.Delete(ID))
            {
                Response.Write("<script>alert('删除成功');window.close(); </script>");
                DataAccess.Multi.System_Multi.addLog(Session["EmployeeID"].ToString(), Session["EmployeeName"].ToString(), 1, new Guid(ViewState["ProjectID"].ToString()), 3);
            }
            else
            {
                Response.Write("<script>alert('删除失败');window.close(); </script>");
            }
        }
        #endregion

        #region 上传附件
        protected void btnUpLoad_Click(object sender, EventArgs e)
        {
            DataAccess.Operate.DA_Report_Attach_Operate Report_Attach_Operate = new DataAccess.Operate.DA_Report_Attach_Operate();
            DataEntity.T_Report_Attach Report_Attach = new DataEntity.T_Report_Attach();
            string sFileName = "";
            string sFilePath = "";
            string sFileType = "";

            Guid gProjectID = new Guid(ViewState["ProjectID"].ToString());
            if (!Directory.Exists("\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString()))
            {
                Directory.CreateDirectory("\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString());
            }
            if (!Directory.Exists("\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString() + "\\" + ViewState["ProjectID"].ToString()))
            {
                Directory.CreateDirectory("\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString() + "\\" + ViewState["ProjectID"].ToString());
            }

            sFileType = CommonFunction.CheckFileType(this.txtFilePath.PostedFile.FileName);
            if (sFileType != "")
            {
                sFileName = ViewState["ProjectID"].ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + sFileType;
            }

            sFilePath = "/ReportManager/" + DateTime.Now.Year + "/" + ViewState["ProjectID"].ToString() + "/" + sFileName;
            try
            {
                Report_Attach.Project_Report_FileDesc = this.txtProjectDesc.Text.Trim();
                Report_Attach.Project_Report_FileName = sFileName;
                Report_Attach.Project_Report_FilePath = sFilePath;
                Report_Attach.Project_Report_ExchangeTypeID = 11;
                Report_Attach.Project_Report_FileID = Convert.ToInt32(this.ddlFileType.SelectedValue);
                Report_Attach.Project_Report_MainID = new Guid(ViewState["ProjectID"].ToString());
                Report_Attach_Operate.Insert(Report_Attach);
                this.txtFilePath.PostedFile.SaveAs("\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString() + "\\" + ViewState["ProjectID"].ToString() + "\\" + sFileName);
                DataAccess.Multi.System_Multi.addLog(Session["EmployeeID"].ToString(), Session["EmployeeName"].ToString(), 5, new Guid(ViewState["ProjectID"].ToString()), 4);
                BindGrid();
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
            finally
            {
                this.ddlFileType.SelectedValue = "";
                Update_Data_Bind(ViewState["ProjectID"].ToString());
            }
        }
        #endregion

        #region 绑定附件GridView
        #region BindGrid
        private void BindGrid()
        {
            DataSet ds = new DataSet();
            DataAccess.Operate.DA_Report_Attach_Inherit Report_Attach_Inherit = new DataAccess.Operate.DA_Report_Attach_Inherit();

            dgList.DataBind();
            ds = Report_Attach_Inherit.GetAllByReportID(ViewState["ProjectID"].ToString());
            dgList.DataSource = ds;
            dgList.DataBind();

            this.HiddenField2.Value = "123"; //随便赋值，以便再次提交时前台验证通过
        }
        #endregion
        #endregion

        #region 附件GridView_ItemDataBound事件
        protected void dgList_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                if (e.Item.ItemIndex > -1)
                {
                    ImageButton imgbtnDelete = (ImageButton)e.Item.FindControl("imgbtnDelete");
                    imgbtnDelete.Attributes.Add("onclick", "return window.confirm(\"是否确定删除？\")");

                }
            }
        }
        #endregion

        #region 附件GridView_ItemCommand事件
        protected void dgList_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            DataAccess.Operate.DA_Report_Attach_Operate Report_Attach_Operate = new DataAccess.Operate.DA_Report_Attach_Operate();
            if (e.CommandName.ToString() == "Delete")
            {
                try
                {
                    Report_Attach_Operate.Delete(new Guid(dgList.DataKeys[e.Item.ItemIndex].ToString()));
                    DataAccess.Multi.System_Multi.addLog(Session["EmployeeID"].ToString(), Session["EmployeeName"].ToString(), 5, new Guid(ViewState["ProjectID"].ToString()), 3);
                    this.BindGrid();
                }
                catch (System.Exception ex)
                {
                    throw new Exception(ex.Message.ToString());
                }
                finally
                {
                    Report_Attach_Operate = null;
                    Update_Data_Bind(ViewState["ProjectID"].ToString());
                }
            }
        }
        #endregion

        #region WebClient上传附件
        /// <summary>
        /// WebClient上传文件至服务器
        /// </summary>
        /// <param name="fileNamePath">文件名，全路径格式</param>
        /// <param name="uriString">服务器文件夹路径</param>
        public void UpLoadFile(string fileNamePath, string uriString)
        {
            /**/
            /// 创建WebClient实例 
            WebClient myWebClient = new WebClient();
            myWebClient.Credentials = CredentialCache.DefaultCredentials;
            // 要上传的文件 
            FileStream fs = new FileStream(fileNamePath, FileMode.Open, FileAccess.Read);
            // FileStream fs = OpenFile(); 
            BinaryReader r = new BinaryReader(fs);
            byte[] postArray = r.ReadBytes((int)fs.Length);
            Stream postStream = myWebClient.OpenWrite(uriString, " PUT ");
            try
            {

                // 使用UploadFile方法可以用下面的格式
                // myWebClient.UploadFile(uriString,"PUT",fileNamePath); 

                if (postStream.CanWrite)
                {
                    postStream.Write(postArray, 0, postArray.Length);
                    postStream.Close();
                    fs.Dispose();
                }
                else
                {
                    postStream.Close();
                    fs.Dispose();

                }
            }
            catch (Exception err)
            {
                postStream.Close();
                fs.Dispose();
                // Utility.LogWriter log = new Utility.LogWriter(); 
                throw err;
            }
            finally
            {
                postStream.Close();
                fs.Dispose();
            }
        }
        #endregion

        #region 审批操作
        protected void btnAudit_Click(object sender, EventArgs e)
        {
            //用按钮的文字来判断审批进行到哪一步
            if (this.btnAudit.Text == "营销[副]总监审核")
            {
                DataAccess.Operate.DA_Project_Inherit Project_Inherit = new DataAccess.Operate.DA_Project_Inherit();
                if (Project_Inherit.AuditByID(ViewState["ProjectID"].ToString(), "3"))
                {

                    DataAccess.Multi.System_Multi.addLog(Session["EmployeeID"].ToString(), Session["EmployeeName"].ToString(), 6, new Guid(ViewState["ProjectID"].ToString()), 5);
                    Response.Write("<script>alert('审核成功');window.close();</script>");
                    //提醒部分负责人审核
                    SendMessage("6", ViewState["ProjectID"].ToString());
                }
            }
            else if (this.btnAudit.Text == "部门负责人审核")
            {

                DataAccess.Operate.DA_Project_Inherit Project_Inherit = new DataAccess.Operate.DA_Project_Inherit();
                if (Project_Inherit.AuditByID(ViewState["ProjectID"].ToString(), "4"))
                {

                    DataAccess.Multi.System_Multi.addLog(Session["EmployeeID"].ToString(), Session["EmployeeName"].ToString(), 6, new Guid(ViewState["ProjectID"].ToString()), 6);
                    Response.Write("<script>alert('审核成功');window.close();</script>");
                    //提醒系统管理员审核
                    SendMessage("7", ViewState["ProjectID"].ToString());
                }

            }
            else if (this.btnAudit.Text == "系统管理员审核")
            {
                DataAccess.Operate.DA_Project_Inherit Project_Inherit = new DataAccess.Operate.DA_Project_Inherit();
                if (Project_Inherit.AuditByID(ViewState["ProjectID"].ToString(), "5"))
                {
                    DataAccess.Multi.System_Multi.addLog(Session["EmployeeID"].ToString(), Session["EmployeeName"].ToString(), 6, new Guid(ViewState["ProjectID"].ToString()), 7);
                    Response.Write("<script>alert('审核成功');window.close();</script>");
                }
            }

        }
        #endregion

        #region 增加人事树
        protected void btnAddHr_Click(object sender, EventArgs e)
        {
            if (txtUserInput.Text.Trim() == "")
                return;
            ListItem item = new ListItem(this.txtUserInput.Text, this.HiddenField1.Value);
            lstHr.Items.Add(item);
            this.txtUserInput.Text = "";
        }
        #endregion

        #region 移除人事树
        protected void btnClear_Click(object sender, EventArgs e)
        {
            int index = lstHr.SelectedIndex;
            if (index > -1)
            {
                lstHr.Items.Remove(lstHr.Items[index]);
            }
        }
        #endregion

        public void SendMessage(string operate, string project)
        {

            string projectNo = "";
            DataAccess.Operate.DA_Project_Inherit Project_Inherit = new DataAccess.Operate.DA_Project_Inherit();
            string[] array = Project_Inherit.getCodeAndName(out projectNo, operate, project);
            string sTitle = "请注意，项目编号:" + projectNo + " 需要您的审批。";
            string sBody = "请注意，项目编号:" + projectNo + " 需要您的审批。<a href='http://gzs-ecc02'>点击此处</a>";
            // array[1] 姓名 ，array[0] 工号
            EcSalseManage.App_Code.CommonFunction.SendMessage(array[1], array[0], sTitle, sBody);

        }

        public void CheckBoxNew(CheckBoxList chkl, DataTable tb)
        {
            for (int i = 0; i < tb.Rows.Count; i++)
            {
                ListItem item = new ListItem(tb.Rows[i][1].ToString(), tb.Rows[i][0].ToString());
                item.Attributes.Add("onclick", "chklAgencyType(this);");
                chkl.Items.Add(item);
            }
        }

        public void RadioButtonNew(RadioButtonList rad, DataTable db)
        {

            for (int i = 0; i < db.Rows.Count; i++)
            {
                ListItem item = new ListItem(db.Rows[i][1].ToString(), db.Rows[i][0].ToString());
                item.Attributes.Add("onclick", "chklAgencyType(this);");
                rad.Items.Add(item);
            }
        }

      

        protected void Button6_Click(object sender, EventArgs e)
        {

            if (!chklAgencyType.Items[3].Selected)   //联动
            {
                if (ddlSignType.SelectedValue == "3")
                {

                }
            }
        }


    }
}